package com.bana.fvs.service;

import com.bana.fvs.dao.VisibilityDAO;
import com.bana.fvs.model.Controller;
import com.bana.fvs.model.Visibility;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class VisibilityService {

    @Resource
    private VisibilityDAO visibilityDAO;

    @Resource
    private ControllerService controllerService;

    public List<Visibility> queryVisibilities(int wqbm)
    {
        List<Visibility> visibilities= visibilityDAO.getVisibilities(wqbm);
        List<Controller> controllers=controllerService.queryControllers(wqbm);
        for(Visibility visibility:visibilities)
        {
            for(Controller controller:controllers)
            {
                if(visibility.getKzqbsm()==controller.getKzqbsm())
                {
                    visibility.setSbzt(controller.getSbzt());
                    visibility.setSbztsm(controller.getSbztsm());
                    visibility.setGxsj(controller.getGxsjsm());
                    break;
                }
            }
        }
        return visibilities;
    }
}
